package com.hebang.stcommunityapp.viewModel;

import android.app.Application;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;

import com.hebang.stcommunityapp.beans.LoginBean;
import com.hebang.stcommunityapp.repostory.Repostory;


public class LoginViewModel extends AndroidViewModel {
    private LoginBean loginModel;
    private MutableLiveData<Boolean> LoginEvent = new MutableLiveData<>();
    public MutableLiveData<Boolean> getLoginEvent() {
        return LoginEvent;
    }
    public LoginViewModel(@NonNull Application application) {
        super(application);
        loginModel = new LoginBean();

    }
    public LoginBean getLoginModel() {
        if (loginModel == null) {
            loginModel = new LoginBean();
        }
        return loginModel;
    }

    /**
     * 与页面中登录按钮绑定的事件
     * @param view
     */
    public void onLoginClickLisenner(View view) {
    String param=    "username="+loginModel.getUsername()+"&password="+loginModel.getPass();
        Repostory.getInstance().doLogin(getApplication(),param,LoginEvent);

    }





}
